﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Microsoft.Phone.Controls;
using Microsoft.Phone.Tasks;
using Microsoft.Phone.Net.NetworkInformation;
using System.IO.IsolatedStorage;

namespace KOF.Views
{
    public partial class Settings : PhoneApplicationPage
    {
        public Settings()
        {

            try
            { //This Code checks internet Connection
                if (NetworkInterface.NetworkInterfaceType != NetworkInterfaceType.None)
                {
                    GoogleAnalytics.EasyTracker.GetTracker().SendView("Settings tab");
                }
                else
                {
                    MessageBox.Show("Please check your internet connection!");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message.ToString());
            }
            // Initialize UI
            InitializeComponent();
        }

        //REdirect to Release Tab
        private void btnReleases_Click(object sender, EventArgs e)
        {
            try
            {

                IsolatedStorageSettings.ApplicationSettings["loader"] = false;
                this.NavigationService.Navigate(new Uri("/Views/MainPage.xaml", UriKind.Relative));

            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message.ToString());
            }
        }

        //Redirect to Favorites Tab
        private void btnFavorites_Click(object sender, EventArgs e)
        {
            try
            {
                this.NavigationService.Navigate(new Uri("/Views/Favorites.xaml", UriKind.Relative));
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message.ToString());
            }
        }

        //Redirect to New Tab
        private void btnNews_Click(object sender, EventArgs e)
        {
            try
            {
                this.NavigationService.Navigate(new Uri("/Views/News.xaml", UriKind.Relative));
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message.ToString());
            }
        }


        //Redirect Fb Page
        private void tbLikeOnFB_MouseEnter(object sender, MouseEventArgs e)
        {
            try
            {
                (App.Current as App).LikeOnSocialMedia = 1;


                this.NavigationService.Navigate(new Uri("/Views/Framefb.xaml", UriKind.Relative));
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message.ToString());
            }
        }

        //Redirect Twitter page
        private void tbFollowOnTW_MouseEnter(object sender, MouseEventArgs e)
        {
            try
            {
                (App.Current as App).LikeOnSocialMedia = 2;

                this.NavigationService.Navigate(new Uri("/Views/Framefb.xaml", UriKind.Relative));
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message.ToString());
            }
        }

        // Redirect Instagram Page
        private void tbFollowOnIG_MouseEnter(object sender, MouseEventArgs e)
        {
            try
            {
                (App.Current as App).LikeOnSocialMedia = 3;

                this.NavigationService.Navigate(new Uri("/Views/Framefb.xaml", UriKind.Relative));
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message.ToString());
            }
        }

        //Share on Fb 
        private void tbShareOnFB_MouseEnter(object sender, MouseEventArgs e)
        {
            try
            {
                ShareOnSocialMediafb();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message.ToString());
            }
        }

        // Share on Twitter
        private void tbShareOnTW_MouseEnter(object sender, MouseEventArgs e)
        {
            try
            {
                ShareOnSocialMediafb();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message.ToString());
            }
        }

        // share On instagram
        private void tbShareOnIG_MouseEnter(object sender, MouseEventArgs e)
        {
            try
            {
                ShareOnSocialMediafb();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message.ToString());
            }
        }

        // Share Function
        private void ShareOnSocialMediafb()
        {
            try
            {
                ShareLinkTask shareOnFB = new ShareLinkTask();
                shareOnFB.Title = "Go download the new @KicksOnFire app for sneaker news and release dates! http://kofapp.com";
                shareOnFB.Message = "Go download the new @KicksOnFire app for sneaker news and release dates! http://kofapp.com";
                shareOnFB.LinkUri = new Uri("http://app.kicksonfire.com/appShare.png", UriKind.Absolute);
                shareOnFB.Show();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message.ToString());
            }


        }




    }
}